<style type="text/css">
    .err_msg{
        display: none;
        font-weight: bold;
        font-style: italic;
        color:red;
    }
</style>
<script typ="text/javascript">
    $(document).ready(function(){
        var flag = true;
        $('#addBtn').click(function(){
            var at = $('#address_type').val();
            var al1 = $('#AddressLine1').val();
            var al2 = $('#AddressLine2').val();
            var ac = $('#AddressCity').val();
            var as = $('#AddressState').val();
            var ac = $('#AddressCountry').val();
            var ap = $('#AddressPIN').val();
            var aph1 = $('#AddressPhone1').val();
            
            $('#groupForm span').hide();
            /*
            $('#AddressType_error').hide();
            $('#AddressLine1_error').hide();
            $('#AddressLine2_error').hide();
            $('#AddressCity_error').hide();
            $('#AddressState_error').hide();
            $('#AddressCountry_error').hide();
            $('#AddressPIN_error').hide();
            $('#AddressPhone1_error').hide();
            */
            if(at == null || at == ''){
                $('#AddressType_error').show();
                $('#AddressType_error').html('<br/>Address Type required');
                flag = false;
            }
            if(al1 == null || al1 == ''){
                $('#AddressLine1_error').show();
                $('#AddressLine1_error').html('Address Line1 required');
                flag = false;
            }
            if(al2 == null || al2 == ''){
                $('#AddressLine2_error').show();
                $('#AddressLine2_error').html('Address Line2 required');
                flag = false;
            }
            if(ac == null || ac == ''){
                $('#AddressCity_error').show();
                $('#AddressCity_error').html('Address City required');
                flag = false;
            }
            if(as == null || as == ''){
                $('#AddressState_error').show();
                $('#AddressState_error').html('Address State required');
                flag = false;
            }
            if(ac == null || ac == ''){
                $('#AddressCountry_error').show();
                $('#AddressCountry_error').html('Address Country required');
                flag = false;
            }
            if(ap == null || ap == ''){
                $('#AddressPIN_error').show();
                $('#AddressPIN_error').html('Address PIN required');
                flag = false;
            }else if(isNaN(ap)){
                $('#AddressPIN_error').show();
                $('#AddressPIN_error').html('Number required for Address PIN');
                flag = false;
            }
            if(aph1 == null || aph1 == ''){
                $('#AddressPhone1_error').show();
                $('#AddressPhone1_error').html('Address Phone1 required');
                flag = false;
            }
            
            return flag;
        });
        
    });
    
</script>
<h1>Add an Address</h1>
<div id="groupForm">
    <form action="/main/profile/addresspost" name="edit_address" id="edit_address" method="post">
        <label for="RecentPhoto">Address type</label>

        <?php 
            $address_type = array(
                  ''=>'---------Please Select---------',
                  'p'=>'Permanent',
                  'c'=>'Communication',
                  'o'=>'Office/Organization'
            );
        ?>

        <select name="address_type" id="address_type">
            <?php foreach($address_type as $key=>$val){?>
            <option value="<?php echo $key?>"><?php echo $val?></option>
            <?php }?>
        </select>
        <span id="AddressType_error" class="err_msg"></span>
        <label for="Address Line1">Address Line1</label>
        <input type="text" name="AddressLine1" id="AddressLine1" value="" class="validate[required] frmInput">
        <span id="AddressLine1_error" class="err_msg"></span>    
        <label for="Address Line1">Address Line2</label>
        <input type="text" name="AddressLine2" id="AddressLine2" value="" class="validate[required] frmInput">
        <span id="AddressLine2_error" class="err_msg"></span>
        <label for="Address City">City</label>
        <input type="text" name="AddressCity" id="AddressCity" value="" class="validate[required] frmInput">
        <span id="AddressCity_error" class="err_msg"></span>
        <label for="Address State">State</label>
        <input type="text" name="AddressState" id="AddressState" value="" class="validate[required] frmInput">
        <span id="AddressState_error" class="err_msg"></span>
        <label for="Address Country">Country</label>
        <input type="text" name="AddressCountry" id="AddressCountry" value="" class="validate[required] frmInput">
        <span id="AddressCountry_error" class="err_msg"></span>
        <label for="AddressPIN">Pin</label>
        <input type="text" name="AddressPIN" id="AddressPIN" value="" class="validate[required] frmInput">
        <span id="AddressPIN_error" class="err_msg"></span>
        <label for="AddressPhone1">Phone1</label>
        <input type="text" name="AddressPhone1" id="AddressPhone1" value="" class="validate[required] frmInput">
        <span id="AddressPhone1_error" class="err_msg"></span>
        <label for="AddressPhone2">Phone2</label>
        <input type="text" name="AddressPhone2" id="AddressPhone2" value="" class="validate[required] frmInput">

        <div class="frm_row">
            <input type="submit" value="Add Address" id="addBtn" class="submitBtn">
        </div>
    </form>
</div>    